var SelectDom = {
	isEmptyContent : function($selectDomObj) {
		var val, txt;
		val = $selectDomObj.val();
		txt = $selectDomObj.find("option:selected").text();
		if (!val) {
			return true;
		} else if (!txt) {
			return true;
		} else if (txt === " ") {
			return true;
		}
		return false;
	},
	hasTxt : function($selectDomObj, txt) {

		var $options, optCnt, i;

		$options = $($selectDomObj.selector + " option");
		optCnt = $options.length;

		for (i = 0; i < optCnt; i++) {
			if ($options[i].text === txt) {
				break;
			}
		}

		return i < optCnt ? true : false;
	},
	hasValue : function($selectDomObj, val) {
		return $($selectDomObj.selector + " option[value='" + val + "']").length > 0 ? true : false;
	},
	initWithValTxt: function($selectDomObj,val,txt){
		$selectDomObj.empty();
		return this.addSelect($selectDomObj, val, txt);
	},
	initWithSpace : function($selectDomObj,ifselect) {
		$selectDomObj.empty();
		if(ifselect){
			$selectDomObj.append("<option value=''> ---------------- </option>");
		}else{
			$selectDomObj.append("<option value='' disabled selected> </option>");
		}
	},
	addSelect : function($selectDomObj, val, txt) {
		var op = $("<option>");
		op.val(val);
		op.text(txt);
		op.appendTo($selectDomObj);
		return $selectDomObj;
	},
	setSelect : function($selectDomObj, val, txt,endFlg) {
//		if (!val) {
//			$selectDomObj.empty();
//			val = val ? val : "";
//			$selectDomObj.val("").trigger("change");
//			return;
//		}
		
		if (this.hasValue($selectDomObj, val)) {
			$selectDomObj.val(val).trigger("change");
		}else if(this.hasTxt($selectDomObj, txt)){
			this.setSelectByTxt($selectDomObj,val,txt);
		}else{
			txt = txt === "" ? " " : txt;
			this.addSelect($selectDomObj, val, txt);
			if(!endFlg){
				this.setSelect($selectDomObj , val, txt,true);
			}
			$selectDomObj.val(val).trigger("change");
		}
	},
	setSelectByTxt : function($selectDomObj,  txt) {
		var $options, optCnt, i;

		$options = $($selectDomObj.selector + " option");
		optCnt = $options.length;

		for (i = 0; i < optCnt; i++) {
			if ($options[i].text === txt) {
				$selectDomObj.get(0).selectedIndex = i;
//				$selectDomObj.val($options[i].value);
			}
		}

	},
	addSelectArr:function($selectDom,arr,valProp,txtProp,checkExistedFlg){
		var i,options;
		if(!arr){
			return false;
		}
		if(!$.isArray(arr)){
			arr = [arr];
		}
		txtProp = (typeof(txtProp)==="undefined" ? valProp :txtProp);
		for(i=0;i<arr.length;i++){
			this.addSelect($selectDom, arr[i][valProp], arr[i][txtProp]);
		}
	},
	setSelectArr:function($selectDomObj,arr,valProp,txtProp){
		var i,oldVal,oldTxt;
		
		if(!$.isArray(arr)){
			arr = [arr];
		}
		txtProp = (typeof(txtProp)=="undefined" ? valProp :txtProp);
		oldVal = $selectDomObj.val();
		oldTxt = $selectDomObj.find("option:selected").text();
		
		for(i=0;i<length;i++){
			this.addSelect($selectDomObj, arr[i][valProp], arr[i][txtProp]);
		}
		
		this.setSelect($selectDomObj, oldVal, oldTxt);
	}

};